<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="120px">
      <!-- <el-form-item label="Relation2" prop="relation2">
        <el-select v-model="queryParams.relation2" placeholder="请选择其他联系人关系" clearable size="small">
          <el-option v-for="dict in relation2Options" :key="dict.dictValue" :label="dict.dictLabel"
            :value="dict.dictValue" />
        </el-select>
      </el-form-item> -->
      <!-- <el-form-item label="母语" prop="nativeLanguage">
        <el-select v-model="queryParams.nativeLanguage" placeholder="请选择母语" clearable size="small">
          <el-option v-for="dict in nativeLanguageOptions" :key="dict.dictValue" :label="dict.dictLabel"
            :value="dict.dictValue" />
        </el-select>
      </el-form-item> -->
      <!-- <el-form-item label="宗教" prop="religion">
        <el-select v-model="queryParams.religion" placeholder="请选择宗教" clearable size="small">
          <el-option v-for="dict in religionOptions" :key="dict.dictValue" :label="dict.dictLabel"
            :value="dict.dictValue" />
        </el-select>
      </el-form-item> -->
      <el-form-item label="UserID" prop="userId">
        <el-input v-model="queryParams.userId" placeholder="请输入用户ID" clearable size="small"
                  @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="SerialNo" prop="applySerialNo">
        <el-input v-model="queryParams.applySerialNo" placeholder="请输入申请流水号" clearable size="small"
                  @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="CustNo" prop="custNo">
        <el-input v-model="queryParams.custNo" placeholder="请输入客户号" clearable size="small"
                  @keyup.enter.native="handleQuery" />
      </el-form-item>
      <!-- <el-form-item label="MonthlyIncome" prop="monthlyIncome">
        <el-select v-model="queryParams.monthlyIncome" placeholder="请选择月收入" clearable size="small">
          <el-option v-for="dict in monthlyIncomeOptions" :key="dict.dictValue" :label="dict.dictLabel"
            :value="dict.dictValue" />
        </el-select>
      </el-form-item> -->
      <el-form-item label="Email" prop="email">
        <el-input v-model="queryParams.email" placeholder="请输入邮箱" clearable size="small"
                  @keyup.enter.native="handleQuery" />
      </el-form-item>
      <!-- <el-form-item label="JobTitle" prop="jobTitle">
        <el-select v-model="queryParams.jobTitle" placeholder="请选择工作职称" clearable size="small">
          <el-option v-for="dict in jobTitleOptions" :key="dict.dictValue" :label="dict.dictLabel"
            :value="dict.dictValue" />
        </el-select>
      </el-form-item> -->
      <!-- <el-form-item label="Industry" prop="industry">
        <el-select v-model="queryParams.industry" placeholder="请选择行业" clearable size="small">
          <el-option v-for="dict in industryOptions" :key="dict.dictValue" :label="dict.dictLabel"
            :value="dict.dictValue" />
        </el-select>
      </el-form-item> -->
      <el-form-item label="MaritalStatus" prop="maritalStatus">
        <el-select v-model="queryParams.maritalStatus" placeholder="请选择婚姻状态" clearable size="small">
          <el-option v-for="dict in maritalStatusOptions" :key="dict.dictValue" :label="dict.dictLabel"
                     :value="dict.dictValue" />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="JobTitleOther" prop="jobTitleOther">
        <el-input v-model="queryParams.jobTitleOther" placeholder="请输入工作职称-其他" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item> -->
      <!-- <el-form-item label="Degree" prop="degree">
        <el-select v-model="queryParams.degree" placeholder="请选择学历" clearable size="small">
          <el-option v-for="dict in degreeOptions" :key="dict.dictValue" :label="dict.dictLabel"
            :value="dict.dictValue" />
        </el-select>
      </el-form-item> -->
      <!-- <el-form-item label="Occupation" prop="occupation">
        <el-select v-model="queryParams.occupation" placeholder="请选择职业" clearable size="small">
          <el-option v-for="dict in occupationOptions" :key="dict.dictValue" :label="dict.dictLabel"
            :value="dict.dictValue" />
        </el-select>
      </el-form-item> -->
      <!-- <el-form-item label="RelateName" prop="relateName">
        <el-input v-model="queryParams.relateName" placeholder="请输入联系人姓名" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item> -->
      <!-- <el-form-item label="联系人手机号码" prop="relatePhone">
        <el-input v-model="queryParams.relatePhone" placeholder="请输入联系人手机号码" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item> -->
      <!-- <el-form-item label="Relation" prop="relation">
        <el-select v-model="queryParams.relation" placeholder="请选择关系" clearable size="small">
          <el-option v-for="dict in relationOptions" :key="dict.dictValue" :label="dict.dictLabel"
            :value="dict.dictValue" />
        </el-select>
      </el-form-item> -->
      <el-form-item label="ApplyStatus" prop="applyStatus">
        <el-select v-model="queryParams.applyStatus" placeholder="请选择申请状态" clearable size="small">
          <el-option v-for="dict in applyStatusOptions" :key="dict.dictValue" :label="dict.dictLabel"
                     :value="dict.dictValue" />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="state" prop="state">
        <el-select v-model="queryParams.state" placeholder="请选择状态" clearable size="small">
          <el-option v-for="dict in stateOptions" :key="dict.dictValue" :label="dict.dictLabel"
            :value="dict.dictValue" />
        </el-select>
      </el-form-item> -->
      <!-- <el-form-item label="职业-其他" prop="occupationOther">
        <el-input v-model="queryParams.occupationOther" placeholder="请输入职业-其他" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item> -->
      <!-- <el-form-item label="FreezeDate" prop="freezeDate">
        <el-input v-model="queryParams.freezeDate" placeholder="请输入冻结期" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" style="margin-left: 37px;">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
                   v-hasPermi="['bizsys:credit_apply:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
                   v-hasPermi="['bizsys:credit_apply:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple"
                   @click="handleDelete" v-hasPermi="['bizsys:credit_apply:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
                   v-hasPermi="['bizsys:credit_apply:export']">导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-refresh" size="mini" @click="handelTriggerAgain"
                   v-hasPermi="['sys:manual:credit']">推送审核
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="credit_applyList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="ID" align="center" width="100" prop="id" />
      <el-table-column label="SerialNo" align="center" width="250" prop="applySerialNo" />
      <el-table-column label="UserID" align="center" width="300" prop="userId" />
      <el-table-column label="CustNo" align="center" width="200" prop="custNo" />
      <el-table-column label="MonthlyIncome" align="center" width="120" prop="monthlyIncome" />
      <el-table-column label="Email" align="center" width="250" prop="email" />
      <el-table-column label="JobTitle" align="center" width="230" prop="jobTitle" :formatter="jobTitleFormat" />
      <el-table-column label="JobTitleOther" align="center" width="200" prop="jobTitleOther" />
      <el-table-column label="Industry" align="center" width="280" prop="industry" :formatter="industryFormat" />
      <el-table-column label="MaritalStatus" align="center" width="200" prop="maritalStatus" :formatter="maritalStatusFormat" />
      <el-table-column label="Degree" align="center" width="220" prop="degree" :formatter="degreeFormat" />
      <el-table-column label="Occupation" align="center" width="180" prop="occupation" :formatter="occupationFormat" />
      <el-table-column label="Relation" align="center" width="100" prop="relation" />
      <el-table-column label="RelateName" align="center" width="150" prop="relateName" />
      <el-table-column label="RelatePhone" align="center" width="150" prop="relatePhone" />
      <el-table-column label="Relation2" align="center" width="100" prop="relation2" />
      <el-table-column label="RelateName2" align="center" width="150" prop="relateName2" />
      <el-table-column label="RelatePhone2" align="center" width="150" prop="relatePhone2" />
      <el-table-column label="SalaryDate" align="center" width="120" prop="salaryDate" :formatter="salaryDateFormat" />
      <el-table-column label="ChildrenNumber" align="center" width="150" prop="childrenNumber" :formatter="childrenNumberFormat" />
      <el-table-column label="ResumptionDate" align="center" width="180" prop="resumptionDate">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.resumptionDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="NativeLanguage" align="center" width="150" prop="nativeLanguage" :formatter="nativeLanguageFormat" />
      <el-table-column label="StateOfResidence" align="center" width="150" prop="stateOfResidence" />
      <el-table-column label="WorkingAddress" align="center" width="350" prop="workingAddress" />
      <el-table-column label="Street" align="center" width="350" prop="street" />
      <el-table-column label="Religion" align="center" prop="religion" :formatter="religionFormat" />
      <el-table-column label="OccupationOther" align="center" width="150" prop="occupationOther" />
      <el-table-column label="FreezeDate" align="center" width="120" prop="freezeDate" />

      <el-table-column label="ApplyStatus" align="center" width="150" prop="applyStatus" :formatter="applyStatusFormat" />
      <el-table-column label="State" align="center" prop="state" :formatter="stateFormat" />

      <el-table-column label="Remark" align="center" width="200" prop="remark" />
      <el-table-column label="createTime" align="center" prop="createTime" width="180">
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
      </el-table-column>
      <el-table-column label="updateTime" align="center" prop="updateTime" width="180">
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
      </el-table-column>

      <el-table-column label="Operation" align="center" width="140"  class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
                     v-hasPermi="['bizsys:credit_apply:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
                     v-hasPermi="['bizsys:credit_apply:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
                @pagination="getList" />

    <!-- 添加或修改授信申请对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="130px">
        <el-form-item label="UserID" prop="userId">
          <el-input v-model="form.userId" placeholder="请输入用户ID" />
        </el-form-item>
        <el-form-item label="SerialNo" prop="applySerialNo">
          <el-input v-model="form.applySerialNo" placeholder="请输入申请流水号" />
        </el-form-item>
        <el-form-item label="CustNo" prop="custNo">
          <el-input v-model="form.custNo" placeholder="请输入客户号" />
        </el-form-item>
        <el-form-item label="MonthlyIncome" prop="monthlyIncome">
          <el-select v-model="form.monthlyIncome" placeholder="请选择月收入">
            <el-option v-for="dict in monthlyIncomeOptions" :key="dict.dictValue" :label="dict.dictLabel"
                       :value="dict.dictValue"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="Email" prop="email">
          <el-input v-model="form.email" placeholder="请输入邮箱" />
        </el-form-item>
        <el-form-item label="JobTitle" prop="jobTitle">
          <el-select v-model="form.jobTitle" placeholder="请选择工作职称">
            <el-option v-for="dict in jobTitleOptions" :key="dict.dictValue" :label="dict.dictLabel"
                       :value="dict.dictValue"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="JobTitleOther" prop="jobTitleOther">
          <el-input v-model="form.jobTitleOther" placeholder="请输入工作职称-其他" />
        </el-form-item>
        <el-form-item label="Industry" prop="industry">
          <el-select v-model="form.industry" placeholder="请选择行业">
            <el-option v-for="dict in industryOptions" :key="dict.dictValue" :label="dict.dictLabel"
                       :value="dict.dictValue"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="MaritalStatus" prop="maritalStatus">
          <el-select v-model="form.maritalStatus" placeholder="请选择婚姻状态">
            <el-option v-for="dict in maritalStatusOptions" :key="dict.dictValue" :label="dict.dictLabel"
                       :value="dict.dictValue"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="Degree" prop="degree">
          <el-select v-model="form.degree" placeholder="请选择学历">
            <el-option v-for="dict in degreeOptions" :key="dict.dictValue" :label="dict.dictLabel"
                       :value="dict.dictValue"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="Occupation" prop="occupation">
          <el-select v-model="form.occupation" placeholder="请选择职业">
            <el-option v-for="dict in occupationOptions" :key="dict.dictValue" :label="dict.dictLabel"
                       :value="dict.dictValue"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="OccupationOther" prop="occupationOther">
          <el-input v-model="form.occupationOther" placeholder="请输入职业-其他" />
        </el-form-item>
        <el-form-item label="RelateName" prop="relateName">
          <el-input v-model="form.relateName" placeholder="请输入联系人姓名" />
        </el-form-item>
        <el-form-item label="RelatePhone" prop="relatePhone">
          <el-input v-model="form.relatePhone" placeholder="请输入联系人手机号码" />
        </el-form-item>
        <el-form-item label="Relation" prop="relation">
          <el-select v-model="form.relation" placeholder="请选择关系">
            <el-option v-for="dict in relationOptions" :key="dict.dictValue" :label="dict.dictLabel"
                       :value="dict.dictValue"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="RelateName2" prop="relateName2">
          <el-input v-model="form.relateName2" placeholder="请输入联系人姓名" />
        </el-form-item>
        <el-form-item label="RelatePhone2" prop="relatePhone2">
          <el-input v-model="form.relatePhone2" placeholder="请输入联系人手机号码" />
        </el-form-item>
        <el-form-item label="Relation2" prop="relation2">
          <el-select v-model="form.relation2" placeholder="请选择关系">
            <el-option v-for="dict in relation2Options" :key="dict.dictValue" :label="dict.dictLabel"
                       :value="dict.dictValue"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="FreezeDate" prop="freezeDate">
          <el-input v-model="form.freezeDate" placeholder="请输入冻结期" />
        </el-form-item>
        <el-form-item label="applyStatus" prop="applyStatus">
          <el-select v-model="form.applyStatus" placeholder="请选择申请状态">
            <el-option v-for="dict in applyStatusOptions" :key="dict.dictValue" :label="dict.dictLabel"
                       :value="parseInt(dict.dictValue)"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="state" prop="state">
          <el-select v-model="form.state" placeholder="请选择状态">
            <el-option v-for="dict in stateOptions" :key="dict.dictValue" :label="dict.dictLabel"
                       :value="dict.dictValue"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="remark" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listCredit_apply,
  getCredit_apply,
  delCredit_apply,
  addCredit_apply,
  updateCredit_apply,
  exportCredit_apply,
  manual_credit
} from "@/api/bizsys/credit_apply";

export default {
  name: "Credit_apply",
  components: {},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 选中数组对象
      rows: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 授信申请表格数据
      credit_applyList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 发薪日期字典
      salaryDateOptions: [],
      // 孩子个数字典
      childrenNumberOptions: [],
      // 其他联系人关系字典
      relation2Options: [],
      // 母语字典
      nativeLanguageOptions: [],
      // 宗教字典
      religionOptions: [],
      // 月收入字典
      monthlyIncomeOptions: [],
      // 工作职称字典
      jobTitleOptions: [],
      // 行业字典
      industryOptions: [],
      // 婚姻状态字典
      maritalStatusOptions: [],
      // 学历字典
      degreeOptions: [],
      // 职业字典
      occupationOptions: [],
      // 关系字典
      relationOptions: [],
      // 申请状态字典
      applyStatusOptions: [],
      // 状态字典
      stateOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        relation2: null,
        relatePhone2: null,
        relateName2: null,
        nativeLanguage: null,
        religion: null,
        userId: null,
        applySerialNo: null,
        custNo: null,
        monthlyIncome: null,
        email: null,
        jobTitle: null,
        industry: null,
        maritalStatus: null,
        jobTitleOther: null,
        degree: null,
        occupation: null,
        relateName: null,
        relatePhone: null,
        relation: null,
        applyStatus: null,
        state: null,
        occupationOther: null,
        freezeDate: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        applySerialNo: [{
          required: true,
          message: "申请流水号不能为空",
          trigger: "blur"
        }],
        custNo: [{
          required: true,
          message: "客户号不能为空",
          trigger: "blur"
        }],
        monthlyIncome: [{
          required: true,
          message: "月收入不能为空",
          trigger: "change"
        }],
        email: [{
          required: true,
          message: "邮箱不能为空",
          trigger: "blur"
        }],
        jobTitle: [{
          required: true,
          message: "工作职称不能为空",
          trigger: "change"
        }],
        industry: [{
          required: true,
          message: "行业不能为空",
          trigger: "change"
        }],
        maritalStatus: [{
          required: true,
          message: "婚姻状态不能为空",
          trigger: "change"
        }],
        degree: [{
          required: true,
          message: "学历不能为空",
          trigger: "change"
        }],
        occupation: [{
          required: true,
          message: "职业不能为空",
          trigger: "change"
        }],
        relateName: [{
          required: true,
          message: "联系人姓名不能为空",
          trigger: "blur"
        }],
        relatePhone: [{
          required: true,
          message: "联系人手机号码不能为空",
          trigger: "blur"
        }],
        relation: [{
          required: true,
          message: "关系不能为空",
          trigger: "change"
        }],
        applyStatus: [{
          required: true,
          message: "申请状态不能为空",
          trigger: "change"
        }],
        state: [{
          required: true,
          message: "状态不能为空",
          trigger: "change"
        }],
        createTime: [{
          required: true,
          message: "创建时间不能为空",
          trigger: "blur"
        }],
        updateTime: [{
          required: true,
          message: "更新时间不能为空",
          trigger: "blur"
        }],
      }
    };
  },
  created() {
    // this.getList();
    this.getDicts("salary_date").then(response => {
      this.salaryDateOptions = response.data;
    });
    this.getDicts("number_of_children").then(response => {
      this.childrenNumberOptions = response.data;
    });
    this.getDicts("relation2").then(response => {
      this.relation2Options = response.data;
    });
    this.getDicts("native_language").then(response => {
      this.nativeLanguageOptions = response.data;
    });
    this.getDicts("religion").then(response => {
      this.religionOptions = response.data;
    });
    this.getDicts("monthly_income").then(response => {
      this.monthlyIncomeOptions = response.data;
    });
    this.getDicts("job_title").then(response => {
      this.jobTitleOptions = response.data;
    });
    this.getDicts("industry").then(response => {
      this.industryOptions = response.data;
    });
    this.getDicts("marital_status").then(response => {
      this.maritalStatusOptions = response.data;
    });
    this.getDicts("education").then(response => {
      this.degreeOptions = response.data;
    });
    this.getDicts("occupation").then(response => {
      this.occupationOptions = response.data;
    });
    this.getDicts("relation").then(response => {
      this.relationOptions = response.data;
    });
    this.getDicts("apply_status").then(response => {
      this.applyStatusOptions = response.data;
    });
    this.getDicts("state").then(response => {
      this.stateOptions = response.data;
    });
  },
  methods: {
    /** 查询授信申请列表 */
    getList() {
      this.loading = true;
      listCredit_apply(this.queryParams).then(response => {
        this.credit_applyList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 发薪日期字典翻译
    salaryDateFormat(row, column) {
      return this.selectDictLabel(this.salaryDateOptions, row.salaryDate);
    },
    // 孩子个数字典翻译
    childrenNumberFormat(row, column) {
      return this.selectDictLabel(this.childrenNumberOptions, row.childrenNumber);
    },
    // 其他联系人关系字典翻译
    relation2Format(row, column) {
      return this.selectDictLabel(this.relation2Options, row.relation2);
    },
    // 母语字典翻译
    nativeLanguageFormat(row, column) {
      return this.selectDictLabel(this.nativeLanguageOptions, row.nativeLanguage);
    },
    // 宗教字典翻译
    religionFormat(row, column) {
      return this.selectDictLabel(this.religionOptions, row.religion);
    },
    // 月收入字典翻译
    monthlyIncomeFormat(row, column) {
      return this.selectDictLabel(this.monthlyIncomeOptions, row.monthlyIncome);
    },
    // 工作职称字典翻译
    jobTitleFormat(row, column) {
      return this.selectDictLabel(this.jobTitleOptions, row.jobTitle);
    },
    // 行业字典翻译
    industryFormat(row, column) {
      return this.selectDictLabel(this.industryOptions, row.industry);
    },
    // 婚姻状态字典翻译
    maritalStatusFormat(row, column) {
      return this.selectDictLabel(this.maritalStatusOptions, row.maritalStatus);
    },
    // 学历字典翻译
    degreeFormat(row, column) {
      return this.selectDictLabel(this.degreeOptions, row.degree);
    },
    // 职业字典翻译
    occupationFormat(row, column) {
      return this.selectDictLabel(this.occupationOptions, row.occupation);
    },
    // 关系字典翻译
    relationFormat(row, column) {
      return this.selectDictLabel(this.relationOptions, row.relation);
    },
    // 申请状态字典翻译
    applyStatusFormat(row, column) {
      return this.selectDictLabel(this.applyStatusOptions, row.applyStatus);
    },
    // 状态字典翻译
    stateFormat(row, column) {
      return this.selectDictLabel(this.stateOptions, row.state);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        salaryDate: null,
        childrenNumber: null,
        resumptionDate: null,
        stateOfResidence: null,
        relation2: null,
        relatePhone2: null,
        street: null,
        relateName2: null,
        nativeLanguage: null,
        workingAddress: null,
        religion: null,
        id: null,
        userId: null,
        applySerialNo: null,
        custNo: null,
        monthlyIncome: null,
        email: null,
        jobTitle: null,
        industry: null,
        maritalStatus: null,
        jobTitleOther: null,
        degree: null,
        occupation: null,
        relateName: null,
        relatePhone: null,
        relation: null,
        applyStatus: null,
        state: null,
        remark: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        occupationOther: null,
        freezeDate: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length

      this.rows = selection;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加授信申请";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getCredit_apply(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改授信申请";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateCredit_apply(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addCredit_apply(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除授信申请编号为"' + ids + '"的数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function() {
        return delCredit_apply(ids);
      }).then(() => {
        this.getList();
        this.msgSuccess("删除成功");
      })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有授信申请数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function() {
        return exportCredit_apply(queryParams);
      }).then(response => {
        this.download(response.msg);
      })
    },
    //手动触发
    handelTriggerAgain() {
      var rows = this.rows;
      var flag = rows.length == 0 ? 0 : 1;
      rows.forEach((item) => {
        if (item.applyStatus != "9") {
          flag = 2;
        }
      });
      if (flag != 1) {
        this.$message({
          message:
            flag == 0
              ? "请至少选择一条 Under Review 的记录"
              : "已选择的记录中包含非 Under Review 的状态",
          type: "warning",
        });
        return;
      }
      var applyNos = rows.map((item) => item.applySerialNo);
      this.loading = true;
      manual_credit(applyNos)
        .then((res) => {
          this.loading = false;
          this.getList();
          this.$alert(res.data, "操作返回", {
            confirmButtonText: "确定",
            callback: (action) => {
              this.$message({
                type: "success",
                message: `操作成功`,
              });
            },
          });
        })
        .catch(() => {
          this.loading = false;
        });
      console.log("发起请求", rows);
    }
  }
};
</script>
